
#ifndef _COM_H_
#define _COM_H_


/***********************************************************************************************************************
**                                                    Includes                                                        **
***********************************************************************************************************************/
#include "Std_Types.h" 


/***********************************************************************************************************************
**                                                  Global Symbols                                                    **
***********************************************************************************************************************/


/***********************************************************************************************************************
**                                                Global Data Types                                                   **
***********************************************************************************************************************/
typedef enum
{
    COM_CHANNEL_ACAN = 0, 
    COM_CHANNEL_CHCAN,
    COM_CHANNEL_MAX
} Com_ChannelType;

/***********************************************************************************************************************
**                                                    Global Data                                                     **
***********************************************************************************************************************/


/***********************************************************************************************************************
**                                                  Global Functions                                                  **
***********************************************************************************************************************/
/*called by Task_Init*/
void Com_Init(void);

/*called by idle task*/
void Com_MainFunction(void);

/*read newest can message by can id.*/
uint8 Com_ReceiveCanData(Com_ChannelType comChannel, uint32 canId, uint8* canDataPtr, uint8* len);

/*send a can message immediately */
void Com_SendCanData(Com_ChannelType comChannel, uint32 canId, uint8* canDataPtr, uint8 Len);

/*this function process Message Timeout and Set Timeout Flag.*/
void Com_MessageTimeout(void);

/*this function Get ICU Timeout Flag.*/
boolean Com_GetICUMessageTimeoutFlag(void);

/*this function Get TBOX Timeout Flag.*/
boolean Com_GetTBOXMessageTimeoutFlag(void);

/*this function Get BCM Timeout Flag.*/
boolean Com_GetBCMMessageTimeoutFlag(void);

/*this function Get INV Timeout Flag.*/
boolean Com_GetINVMessageTimeoutFlag(void);

/*this function Get OBC Timeout Flag.*/
boolean Com_GetOBCMessageTimeoutFlag(void);

/*this function Get ACAN Busoff Flag.*/
boolean Com_GetACANBusoffFlag(void);

/*this function Get CHCAN Busoff Flag.*/
boolean Com_GetCHCANBusoffFlag(void);

/*communication control*/
void Com_DisableTx(uint8 comChannel);
void Com_EnableTx(uint8 comChannel);
void Com_DisableRx(uint8 comChannel);
void Com_EnableRx(uint8 comChannel);


/*
 * Callback Function
 */
/*this function indicates a successful reception of a received CAN message.*/
void Com_RxIndication(Com_ChannelType comChannel, uint32 canId, uint8 Frame_Type, uint8 canDlc, uint8 const* canDataPtr);

/*this function indicates a can busoff*/
void Com_BusOffIndication(Com_ChannelType comChannel);

/*this function confirms a previously successful processed transmission of a CAN message.*/
void Com_TxConfirmation(Com_ChannelType comChannel);


#endif /*_COM_H_*/

/**********************************************************************************************************************
 *  END OF FILE: Com.h
 *********************************************************************************************************************/


